package com.system;

import java.awt.*;
import java.awt.event.MouseEvent;

public class Pen {
    public static int x1,y1,x2,y2;
    private static int state = 1;

    public void draw(MouseEvent e , Graphics g) {
        switch(getState()){
            case 1 :
                x1 = e.getX();
                y1 = e.getY();
                setState(2);
                break;
            case 2 :
                x2 = e.getX();
                y2 = e.getY();
                g.drawLine(x2,y2,x1,y1);
                setState(3);
                break;
            case 3 :
                x1 = e.getX();
                y1 = e.getY();
                g.drawLine(x2,y2,x1,y1);
                setState(2);
                break;
        }
    }

	public int getState() {
		return state;
	}

	public void setState(int state) {
		Pen.state = state;
	}
}

